<?php
/**
 * Created by PhpStorm.
 * User: jungshen
 * Date: 2018/8/1
 * Time: 11:26
 */
namespace app\api\validate;

use think\Validate;

class WorkerInfo extends Validate
{
    protected $rule = [
        'name'  =>  'require|chs|max:10',
        'sex|性别'  =>  'require|chs|in:男,女',
        'work_type_ids' =>  'require',
        'work_price' =>  'require|integer|gt:0',
        'skill' =>  'require',
        'phone' =>  'require|mobile',
        'birthday' =>  'require|date',
        'province' =>  'require|number|gt:0',
        'city' =>  'require|number|gt:0',
        'district' =>  'require|number|gt:0',
        'address|详细地址' =>  'require|min:3',
        'lng' =>  'require',
        'lat' =>  'require',
        'headimg|头像' =>  'url',
        'good_at|个人擅长' =>  'require|max:40',
        'grade_id' =>  'require|integer|gt:0',
        'code|微信CODE' =>  'require',
    ];

    protected $message  =   [
        'name.require' => '姓名不能为空',
        'name.chs' => '姓名只能是汉字',
        'name.max'     => '姓名最多10个字符',
        'work_type_ids.require' => '至少选择一项工种',
        'work_price.require' => '工价不能为空',
        'work_price.integer' => '工价只能是数字',
        'work_price.gt' => '工价必须大于0',
        'skill.require' => '至少选择一项技能',
        'phone.require' => '手机号不能为空',
        'phone.mobile' => '手机号格式不正确',
        'birthday.require' => '出生日期不能为空',
        'birthday.date' => '出生日期格式不正确',
        'province.require' => '省份不能为空',
        'province.number' => '省份格式不正确',
        'province.gt' => '省份格式不正确',
        'city.require' => '城市不能为空',
        'city.number' => '城市格式不正确',
        'city.gt' => '城市格式不正确',
        'district.require' => '区县不能为空',
        'district.number' => '区县格式不正确',
        'district.gt' => '区县格式不正确',
        'lng.require' => '位置获取失败',
        'lat.require' => '位置获取失败',
        'grade_id.require' => '入驻方式不能为空',
        'grade_id.integer' => '入驻方式格式不正确',
        'grade_id.gt' => '入驻方式格式不正确',
    ];

    public function sceneEdit()
    {
        return $this->remove('grade_id')
            ->remove('code')
            ->remove('birthday');
    }
}